﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace WeChatParking.Repository
{
    /// <summary>
    /// 数据库辅助类
    /// </summary>
    public static class DbHelper
    {
        /// <summary>
        /// 数据库连接串
        /// </summary>
        public static string ConnectionString
        {
            get
            {
                //return "Data Source=.\\sql2012;Initial Catalog=WeChatParking;User ID=sa;Password=1015;";
                return System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            }
        }

        /// <summary>
        /// 获取数据库连接。连接已打开，需手动关闭。建议用Using方式调用
        /// </summary>
        /// <returns></returns>
        public static IDbConnection Connection
        {
            get
            {
                IDbConnection conn = new System.Data.SqlClient.SqlConnection(ConnectionString); // new MySql.Data.MySqlClient.MySqlConnection(ConnectionString);
                //conn.Open();
                return conn;
            }
        }
    }
}
